package com.nitobi.test
{
	import com.nitobi.util.Encryption;
	import com.nitobi.util.SettingsUtil;
	
	import flash.data.EncryptedLocalStore;
	
	import flexunit.framework.TestCase;	
	
	public class SettingsUtilTest extends TestCase
	{
		public function testSettingsExist():void
		{
			EncryptedLocalStore.reset();

			Encryption.writeEncryptedStringSetting("coopUser", "coop user name");
			Encryption.writeEncryptedStringSetting("coopPass", "coop password");				
			
			// company name can be gotten via coop API -> GET /users/#{user_id}/harvest_credential
			Encryption.writeEncryptedStringSetting("companyName", "harvest company name");
			Encryption.writeEncryptedStringSetting("harvestUser", "harvest user name");
			Encryption.writeEncryptedStringSetting("harvestPass", "harvest password");
			
			assertTrue("isMissingSettings should return false", SettingsUtil.isMissingSettings() == false);		
		}
		
		public function testSettingsDoNotExist():void
		{
			EncryptedLocalStore.reset();
			assertTrue("isMissingSettings should return true", SettingsUtil.isMissingSettings() == true);		
		}

	}
}